package com.bwie.controller;

import com.bwie.pojo.TbCoupon;
import com.bwie.service.TbCouponService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/7/9 20:23
 * @Version 1.0
 */
@RestController
@RequestMapping("/win/coupon")
public class CouponController {
    @Autowired
    TbCouponService tbCouponService;

    /**
     * 获取优惠券列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getCouponList")
    public R getCouponList(@RequestBody PageInfoVo pageInfoVo){
        return tbCouponService.getCouponList(pageInfoVo);
    }

    /**
     * 添加优惠券
     * @param tbCoupon
     * @return
     */
    @PostMapping("/addCoupon")
    public R addCoupon(@RequestBody @Validated TbCoupon tbCoupon){
        return tbCouponService.addCoupon(tbCoupon);
    }

    /**
     * 根据优惠券ID领取
     * @param couponId
     * @return
     */
    @PostMapping("/claimCoupon/{couponId}")
    public R claimCoupon(@PathVariable("couponId") Integer couponId){
        return tbCouponService.claimCoupon(couponId);
    }

    /**
     * 获取领取记录分页列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getCouponRecordList")
    public R getCouponRecordList(@RequestBody PageInfoVo pageInfoVo){
        return tbCouponService.getCouponRecordList(pageInfoVo);
    }
}
